import http from '@/http'
import type {LoginParam, SysUser, UpdatePasswordParam, UserParam} from "@/api/user/UserModel.ts";

//添加角色
export const addApi = function (pram: SysUser) {
    return http.post('api/sysUser/add', pram)
}
//分页查询角色列表
export const getListApi = (pram: UserParam) => {
    return http.get('api/sysUser/getList', pram)
}

export const editApi = (param: SysUser) => {
    return http.put('api/sysUser', param)
}

export const delApi = (userId: string) => {
    return http.delete(`api/sysUser/${userId}`)
}
//检验用户名是否存在
export const checkUserNameApi = (username: string) => {
    return http.get('api/sysUser/checkUserName', {userName: username})
}
//获取角色列表
export const getRoleListApi = (userId: string) => {
    return http.get('api/sysUser/getRoleList', {userId: userId})
}
export const resetPasswordApi = (param: SysUser) => {
    return http.post('api/sysUser/resetPassword', param)
}
//获取验证码
export const getImageApi = () => {
    return http.post('api/sysUser/getImage')
}
//登陆
export const loginApi = (param: LoginParam) => {
    return http.post('api/sysUser/login', param)
}
//修改密码
export const updatePasswordApi = function (pram: UpdatePasswordParam) {
    return http.post('api/sysUser/updatePassword', pram)
}
export const logoutApi = function () {
    return http.post('api/sysUser/logout')
}

//获取用户信息
export const getUserInfoApi = (userId: string) => {
    return http.get('api/sysUser/getUserInfo', {userId: userId})
}